﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Model;

namespace zjbks
{
    public partial class ChenJiChaXun : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   //获取ID 利用登入的session获取
            string id = Session["id"].ToString();
            //根据ID获取成绩根据ID查询成绩表
            Model.ScoreInfoEntity Model = new Model.ScoreInfoEntity();
            BLL.BScoreInfo bll = new BLL.BScoreInfo();
            Model = bll.GetScoreInfo(id);
            if (Model == null)
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('成绩未出');</script>");
                Response.Redirect("KaoShengIndex.aspx");
                return;
            }
            Math.Text = Convert.ToString(Model.Math);
            Enlign.Text = Convert.ToString(Model.Eng);
            ZYK.Text = Convert.ToString(Model.SubjectScore);
            //根据ID获取报考专业，根据ID 查询准考证号表
            Model.ZKZEntity Model3 = new Model.ZKZEntity();
            BLL.BZKZ bll3 = new BLL.BZKZ();
            Model3 = bll3.GetZKZ(id);
            string subjectname = Model3.Subject;
            //根据报考专业获取分数线，通过专业名查询专业表   
            BLL.BSubjectInfo bll2 = new BLL.BSubjectInfo();
            Model.SubjectInfoEntity Model2 = new Model.SubjectInfoEntity();
            string sql = "select Score from SubjectInfo where SubjectName='" + subjectname + "'";
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["zjbksConnectionString"].ConnectionString);
            conn.Open();
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = sql;
            Object ob = new Object();
            ob = cmd.ExecuteScalar();
            conn.Close();
            Model2.Score = Convert.ToInt32(ob.ToString());
            FSX.Text = Convert.ToString(Model2.Score);
            int math = Convert.ToInt32(Model.Math);
            int eng = Convert.ToInt32(Model.Eng);
            int zyk = Convert.ToInt32(Model.SubjectScore);
            int sum = math + eng + zyk;
            int fenshuxian = Model2.Score;
            Session["success"] = sum > fenshuxian;
            if (sum > fenshuxian)
            {
                Label1.Text = "恭喜你过线了";
            }
            else
            {
                Label1.Text = "抱歉，你没有过线";
            }
        }
    }
}